package com.ruoyi.exam.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamConflict;
import com.ruoyi.exam.service.IExamConflictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 冲突检测管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/exam/conflict")
public class ExamConflictController extends BaseController
{
    @Autowired
    private IExamConflictService examConflictService;

    /**
     * 查询冲突检测管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:conflict:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamConflict examConflict)
    {
        startPage();
        List<ExamConflict> list = examConflictService.selectExamConflictList(examConflict);
        return getDataTable(list);
    }

    /**
     * 导出冲突检测管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:conflict:export')")
    @Log(title = "冲突检测管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamConflict examConflict)
    {
        List<ExamConflict> list = examConflictService.selectExamConflictList(examConflict);
        ExcelUtil<ExamConflict> util = new ExcelUtil<ExamConflict>(ExamConflict.class);
        util.exportExcel(response, list, "冲突检测管理数据");
    }

    /**
     * 获取冲突检测管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:conflict:query')")
    @GetMapping(value = "/{conflictId}")
    public AjaxResult getInfo(@PathVariable("conflictId") Long conflictId)
    {
        return success(examConflictService.selectExamConflictByConflictId(conflictId));
    }

    /**
     * 新增冲突检测管理
     */
    @PreAuthorize("@ss.hasPermi('exam:conflict:add')")
    @Log(title = "冲突检测管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamConflict examConflict)
    {
        return toAjax(examConflictService.insertExamConflict(examConflict));
    }

    /**
     * 修改冲突检测管理
     */
    @PreAuthorize("@ss.hasPermi('exam:conflict:edit')")
    @Log(title = "冲突检测管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamConflict examConflict)
    {
        return toAjax(examConflictService.updateExamConflict(examConflict));
    }

    /**
     * 删除冲突检测管理
     */
    @PreAuthorize("@ss.hasPermi('exam:conflict:remove')")
    @Log(title = "冲突检测管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{conflictIds}")
    public AjaxResult remove(@PathVariable Long[] conflictIds)
    {
        return toAjax(examConflictService.deleteExamConflictByConflictIds(conflictIds));
    }
}
